var Picker = function() {

	this.init = function(container) {
		var offsetX = 0;
		var offsetY = 0;
		for (var y = 0; y < 704; y += 32) {
			for (var x = 0; x < 512; x += 32) {
				cell = document.createElement("div");
				cell.id = x+'x'+y;
				cell.style.backgroundPosition = '-'+x+' -'+y;
				cell.onclick = this.pick;
				$(container).appendChild(cell);
				offsetX += 32;
				if (offsetX >= 128) {
					offsetX = 0;
					offsetY += 32;
				}
			}
		}
	}

	this.pick = function(e) {
		pickedCell = e.toElement;
		coordinates = pickedCell.id;
		coordinates = coordinates.split('x');
		map.sprites.grass.bgx = coordinates[0];
		map.sprites.grass.bgy = coordinates[1];
	}
};